﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using EvertonApp.Data.UnitOfWork;
using EvertonApp.Transporte;

namespace EvertonApp.WebAPI.Controllers
{
    public class EventoController : ApiController
    {
        private ForoUoW _foro;

        public EventoController()
        {
            this._foro = new ForoUoW();
        }

        // GET api/evento
        public IEnumerable<Evento> Get()
        {
            IQueryable<Evento> eventos = _foro.EventosRepository.GetAll();

            return eventos.AsEnumerable();
        }

        // GET api/evento/5
        public Evento Get(Guid id)
        {
            return _foro.EventosRepository.GetById(id);
        }

        // POST api/evento
        public Evento Post([FromBody]Evento value)
        {
          return _foro.EventosRepository.Insert(value);
        }

        // PUT api/evento/5
        public bool Put(Guid id, [FromBody]Evento value)
        {
           return _foro.EventosRepository.Update(id, value);
        }

        // DELETE api/evento/5
        public bool Delete(Guid id)
        {
           return _foro.EventosRepository.Delete(_foro.EventosRepository.GetById(id));
        }
    }
}
